#ifndef ENGINE
#define ENGINE

#include "../device/device.h"
#include "../../node/node.h"
#include "../../texture/fbo.h"

#include "../../node/billboard/billboard.h"
#include "../../node/billboard/sprite.h"
#include "../../node/camera/camera.h"
#include "../../node/camera/freefly.h"
#include "../../node/camera/trackball.h"
#include "../../node/light/directional.h"
#include "../../node/light/projector.h"
#include "../../node/light/spot.h"
#include "../../node/light/sun.h"
#include "../../node/physics/physics.h"
#include "../../node/physics/ragdoll.h"
#include "../../node/physics/softbody.h"
#include "../../node/real/natif.h"
#include "../../node/real/octree.h"
#include "../../node/real/grid.h"
#include "../../node/sky/dynamic.h"
#include "../../node/sky/skybox.h"
#include "../../node/sky/skydome.h"

namespace sleek
{
    namespace core
    {
        namespace engine
        {
            class world;
            class engine
            {
                public:
                    engine(world*);
                    virtual ~engine();

                    node::Node *addSceneNode(node::Node*);
                    core::u32   getNumberNode(){ return nd.size(); }
                    node::Node *getNode(core::u32 i){ return nd[i]; }
                    void removeNode(node::Node*);

                    void reloadScene();
                    void loadScene(const char*);
                    void saveScene(const char*);
                    void clear();

                    void setFog(core::f32 start, core::f32 end, core::f32 density, texture::pixel color);

                    void enableDebugDraw(bool);
                    bool isDebugDraw();

                    world *getWorld();
                    device::Device *getDevice();
                    texture::draw *getDrawManager();
                    node::camera::Camera *getCamera();
                    btDiscreteDynamicsWorld *getPhysics();

                    void render();
                protected:
                    device::Device *screen;
                    node::camera::Camera *cm;
                    texture::draw *mom;

                    btDiscreteDynamicsWorld *phy;
                    btBroadphaseInterface *broadphase;
                    btCollisionDispatcher *dispatcher;
                    btDefaultCollisionConfiguration *collision;
                    btSequentialImpulseConstraintSolver *impulse;
                private:
                    bool debug_draw;
                    world *manager;
                    core::math::array<node::Node*> nd;
                    const char  *currentScene;
                private:
//                    friend class node::camera::Camera;
                    friend void* FunctionThreadPhysics(void *data);
                    friend void* FunctionThreadSound  (void* data);
                    friend void* FunctionThreadEvent  (void* data);
                    friend void* FunctionThreadRender (void* data);
            };
        }
    }
}
#endif // ENGINE_H
